package com.itheima2;


import java.io.File;

public class Work06 {
    public static void main(String[] args){
        File file = new File("D:\\itcast");
        long len = length(file);
        System.out.println(len+"字节");
    }
    public static long length(File file){
        long len=0;
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()){
                len+=file1.length();
            }else {
                len+=length(file1);
            }
        }

return len;
    }
}
